require("../../utils/util.js");

Page({
    data: {
        strToShare: ""
    },
    onLoad: function(o) {
        var a = o.imageUrl;
        this.setData({
            imageUrl: a
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    bindTextAreaBlur: function(o) {
        var a = o.detail.value;
        this.setData({
            strToShare: a
        });
    },
    sharePic: function() {
        var o = wx.cloud.database().collection("shareImage"), a = this.data, e = Date.now() + ".png";
        wx.showLoading({
            title: "上传中..."
        }), console.log(e), wx.cloud.uploadFile({
            cloudPath: e,
            filePath: a.imageUrl,
            success: function(e) {
                o.add({
                    data: {
                        shareImageUrl: e.fileID,
                        shareStr: a.strToShare
                    },
                    success: function(o) {
                        console.log(o), wx.hideLoading(), wx.showToast({
                            title: "上传成功",
                            icon: "success"
                        }), setTimeout(function() {
                            wx.navigateBack({});
                        }, 1e3);
                    }
                });
            },
            fail: console.error
        });
    }
});